package com.Java.train.member.controller;

import com.Java.train.common.response.CommonResp;
import com.Java.train.member.domain.DTO.MemberDTO;
import com.Java.train.member.req.MemberLoginReq;
import com.Java.train.member.req.MemberReq;
import com.Java.train.member.req.MemberSendCodeReq;
import com.Java.train.member.service.MemberService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController()
public class MemberController {
    @Autowired
    private MemberService memberService;
    @GetMapping("/count")
    private int count(){
        return (int) memberService.count();
    }

    @PostMapping("/register")
    private CommonResp<Long> register(@Valid @RequestBody MemberReq memberReq){
        return memberService.register(memberReq);
    }

    @PostMapping("/send-code")
    private CommonResp<Long> sendCode(@Valid @RequestBody MemberSendCodeReq sendCodeReq){
        return memberService.sendCode(sendCodeReq);
    }

    @PostMapping("/login")
    private CommonResp<MemberDTO> login(@Valid @RequestBody MemberLoginReq memberLoginReq){
        return memberService.login(memberLoginReq);
    }
}
